package com.example.demo.lc.dp;

/**
* @author wzh
* @date 2021/7/21 3:00 下午
* @Description   dp    https://leetcode-cn.com/problems/nim-game/
*/
public class LeetCode292 {
    public static void main(String[] args) {
        System.out.println(canWinNim(8));
    }

    /**
    * @author wzh
    * @date 2021/7/21 3:06 下午
    * @Description     动态规划
    */
    public static boolean canWinNim(int n) {
        if(n<=3){
            return true;
        }
        boolean[] dp = new boolean[n+1];
        dp[1] = true;
        dp[2] = true;
        dp[3] = true;
        for (int i = 4; i <= n; i++) {
            dp[i] = !(dp[i-1]&&dp[i-2]&&dp[i-3]);
        }
        return dp[n];
    }

    public static boolean canWinNim1(int n) {
        return (n%4!=0);
    }
}
